package com.huifer.wgx.controller;

import com.huifer.wgx.pojo.CommonResult;
import com.huifer.wgx.service.OperationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>Title : OperationController </p>
 * <p>Description : 操作</p>
 *
 * @author huifer
 * @date 2019-03-15
 */
@RestController
@RequestMapping("operation")
@Api(tags = "OperationController", description = "操作管理")
public class OperationController {

    @Autowired
    private OperationService operationService;
    private CommonResult commonResult = new CommonResult();

    @ApiOperation("查看所有操作记录")
    @GetMapping("/find_all")
    public ResponseEntity findAllOp(
            @RequestParam("pagenum") Integer pageNum,
            @RequestParam("pagesize") Integer pageSize) {
        try {
            return ResponseEntity.ok(commonResult.success(operationService.findAll(pageNum, pageSize)));
        } catch (Exception e) {
            return ResponseEntity.badRequest().body(commonResult.fialed(e));
        }
    }


}
